<?php

namespace App\Validator\Admin\Content;

use App\Constants\Common\CommonCode;
use App\Constants\Content\AdCode;
use App\Validator\BaseValidator;
use Hyperf\Validation\Rule;

class NoticeValidator extends BaseValidator
{

    protected array $attr = [
        'id' => '公告id',
        'ids' => '公告id',
        'sort' => '排序值',
        'show_status' => '显示状态',
        'title' => '标题',
        'content' => '内容',
    ];

    public function pageList($data)
    {
        return $this->validatePage($data,[
            'show_status' => ['nullable','integer',],
            's_title' => ['nullable','string',],
        ]);
    }

    public function add($data)
    {
        return $this->validate($data,[
            'sort' => ['required','integer','min:0'],
            'show_status' => ['required','integer',Rule::in(CommonCode::validSwitch())],
            'title' => ['required','string',],
            'content' => ['required','string',],
        ]);
    }

    public function detail($data)
    {
        return $this->validate($data,[
            'id' => ['required','integer','min:1'],
        ]);
    }

    public function update($data)
    {
        return $this->validate($data,[
            'id' => ['required','integer','min:1'],
            'sort' => ['required','integer','min:0'],
            'show_status' => ['required','integer',Rule::in(CommonCode::validSwitch())],
            'title' => ['required','string',],
            'content' => ['required','string',],
        ]);
    }

    public function del($data)
    {
        return $this->validate($data,[
            'ids' => ['required','array','min:1'],
            'ids.*' => ['required','integer','min:1'],
        ]);
    }


}
